<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head >
    <title>搜索管理后台 - 总词库管理</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<link rel="stylesheet" type="text/css" href="${request.contextPath}/css/style_manager.css">
	<script type="text/javascript" src="${request.contextPath}/js/jquery-1.4.2.js"></script>
	<script type="text/javascript" src="${request.contextPath}/js/manager.js"></script>
	<script type="text/javascript" src="${request.contextPath}/js/my97/WdatePicker.js"></script>
	<script type="text/javascript" src="${request.contextPath}/js/jquery.overblock-1.2.js"></script>
		
	<script type="text/javascript">
	var list = null;
	$(function(){
		
		$('input.number').bind('keyup', function(){
			$(this).val($(this).val().replace(/[^\d]/g, ''));
		}).bind('blur', function(){
			if($(this).val().length < 1){
				$(this).val(0);
			}
		});
		
		list = new ListObject('list', 'dataDiv', 'pageNumDiv');
		list.init();
		list.list(1, function(){
			initEvent();
		});
	});
	
	var timeoutEvent = null;
	var isTimeout = false;
	
	var singleTimeoutEvent = null;
	var isSingle = false;
	function initEvent(){
	
		$('#batchDo,div#batchDiv').bind('mouseover', function(e){
			var o = $('#batchDo');
			var x = o.position().left;
			var y = o.position().top;
			var bo = $('#batchDiv');
			var bx = x + o.width() + 25;
			var by = y - bo.height() + 8;
			bo.css({'top':by + 'px','left':bx + 'px'});
			isTimeout = false;
			$('#batchDiv').fadeIn(0);
		});
		$('#batchDo,div#batchDiv').bind('mouseout', function(e){
			/*for(var i in e){
				if(i.indexOf('re') > -1){
					alert(i);
				}
			}*/
			isTimeout = true;
			clearTimeout(timeoutEvent);
			timeoutEvent = setTimeout(function(){
				if(isTimeout){
					var tar = $(e.relatedTarget);
					if(tar.parents('div.batchDiv').length <= 0 && (tar.attr('id') != 'batchDiv')){
						$('#batchDiv').fadeOut(0);
					}
				}
			},600);
		});
		$('#listTable td.moreOptTd a.moreOpt').live('click', function(){
			var o = $(this);
			var x = o.position().left + $(this).parent('td').width() - 20;
			var y = o.position().top;
			
			$('#hiddenKeyid').val(o.parents('tr.bgTr').find('input.checkBoxes').val());
			$('#sameKeyword,#industryWordInput').val(o.html());
			
			$('#singleDiv').stop(true, true).animate({top:y,left:x},300).fadeIn(0);
			clearTimeout(singleTimeoutEvent);
			isSingle = true;
			singleTimeoutEvent = setTimeout(function(){
				if(isSingle){
					$('#singleDiv').stop(true, true).fadeOut(300);
				}
			}, 1800);
		});
		$('#singleDiv').live('mouseover', function(){
			isSingle = false;
			clearTimeout(singleTimeoutEvent);
		}).live('mouseout', function(e){
			var o = $(e.relatedTarget);
			isSingle = false;
			clearTimeout(singleTimeoutEvent);
			if(o.attr('id') != 'singleDiv' && o.parents('#singleDiv').length <= 0){
				$('#singleDiv').stop(true, true).fadeOut(300);
			}
		});
		
		
		$('#addCate').click(function(){
			$('#addCateInfo').showPop({'blockStyle':{color:'#dddddd'}, 'closeable':false, 'fadeTime':300});
		});
		$('#closeCate').click(function(){
			$('#addCateInfo').hidePop(300);
		});
		
		var floatObj_ = {'blockStyle':{color:'#dddddd'}, 'closeable':false, 'fadeTime':300};
		$('#sameWordId').click(function(){
			$('#sameWordFloat').showPop(floatObj_);
		});
		$('#industryWordId').click(function(){
			$('#industryWordFloat').showPop(floatObj_);
			$('#industryAddWord').focus();
		});
		
		$('a.aEdit').live('click', function(){
			var o = $(this);
			var op = o.parents('tr.bgTr');
			var keyword = op.find('a.moreOpt').html();
			var keyid = op.find('input.checkBoxes').val();
			var cate = op.children('td:eq(2)').html();
			$('#baseWordEditorKeyword').val(keyword);
			$('#baseWordEditorkeyid').val(keyid);
			
			var oselect = $('#baseWordEditorSelect');
			oselect.find('option').each(function(){
				var html = $(this).html();
				if(html == cate){
					$(this).attr('selected', 'selected');
				}
			});
			$('#baseWordEditor').showPop({'blockStyle':{color:'#777777'}, 'closeable':true});
		});
	}
	function ListData(n, func){
		$('#singleDiv').fadeOut(0);
		list.list(n, func);
	}
	var sortType = 1;
	function sortData(f){
		var s = f || '';
		s = (sortType > 0 ? '' : '-') + s;
		sortType = sortType * -1;
		$('#sortInput').val(s);
		ListData(1)
	}
	function reset(){
		$('#bdate,#edate,#keyword,#sortInput').val('');
		$("#allCateSelect option:eq(0)").attr('selected', 'selected');
		ListData(1)
	}
	//批量删除
	function batchDelete(){
		var ids = getids();
		if(ids == null || ids.length < 1){
			return;
		}
		if(!confirm('确定批量删除？')){
			return;
		}
		var url = 'delete?ids=' + ids;
		ajax(url, function(rs){
			if(rs == 1){
				s = '批量删除成功！';
			}else{
				s = '批量删除失败！';
			}
			showRs(s);
			ListData()
		});
	}
	
	function doBatchCate(){
		var ids = getids();
		var cateid = $('#cateInfoHTML #allCateSelect').val();
		ajax('baseSetCate?ids='+ids+'&cateId='+cateid, function(rs){
			reloadPage();
		});
	}
	
	//加入行业词汇
	function batchDo(id){
		var ids = '';
		if(id){
			ids = $('#hiddenKeyid').val();
		}else{
			ids = getids();
		}
		if(ids == null || ids.length < 1){
			return;
		}
		ajax('copyToTest?ids='+ids, function(rs){
			reloadPage();
		});
	}

	function getids(){
		$('#batchDiv').fadeOut(0);
		var chboxes = $('input[type="checkbox"][class="checkBoxes"]').filter(':checked');
		if(chboxes.length <= 0){
			alert("请选择数据。");
			return '';
		}
		var ids = chboxes.map(function(){
			return $(this).val();
		}).get().join(',');
		return ids;
	}
	
	function deleteData(id){
		if(!confirm("确定删除？")){
			return;
		}
		var url = 'delete?ids=' + id;
		ajax(url, function(rs){
			if(rs == 1){
				s = '删除成功！';
			}else{
				s = '删除失败！';
			}
			showRs(s);
			ListData()
		});
	}
	function saveBaseword(){
		var bkey = $('#baseWordEditorKeyword').val();
  		var bid = $('#baseWordEditorkeyid').val();
  		var cid = $('#baseWordEditorSelect').val();
  		ajax('../manager/editBaseword?ids='+bid+'&keyword='+bkey+'&cateId=' + cid, function(rs){
			if(rs == 1){
				s = '编辑成功！';
			}else{
				s = '编辑失败！';
			}
			showRs(s);
			ListData()
			$('#baseWordEditor').hidePop();
  		});
	}
	//批量热门
	function batchHot(){
		var ids = getids();
		if(ids == null || ids.length < 1){
			return;
		}
		var url = 'copyToHot?ids=' + ids;
		ajax(url, function(rs){
			if(rs == 1){
				s = '批量设为热门词成功';
			}else{
				s = '批量设为热门词失败！';
			}
			showRs(s);
			ListData()
		});
	}
	</script>
	<style type="text/css">
	#table1 td{
		font-size:13px;
	}

	input.number{
		border-radius:3px;
		border:1px solid gray;
		height:22px;
		padding-left:5px;
	}
	input.btn{
		border-radius:5px;height:25px;border:1px solid #aaaaaa;
	}
	input.inputBox{
		border-radius:4px;
		border:1px solid #aaaaaa;
		height:23px;
		padding-left:5px;
	}
	</style>
  </head>
  <body>
  	<div id="containerDiv">
  		<div style="">
			<h3>总词库管理</h2>
  		</div>
  		<div style="font-size:13px;padding:5p;margin-bottom:20px;">
			日期：从
			<input type="text" class="inputBox" value="" readOnly="readOnly" onclick="WdatePicker({el:'bdate',dateFmt:'yyyy-MM-dd HH:mm:ss'});" id="bdate" size="16" />
			到
			<input type="text" class="inputBox" value="" readOnly="readOnly" id="edate" size="16" onclick="WdatePicker({el:'edate',dateFmt:'yyyy-MM-dd HH:mm:ss'});" />
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;类别：
			<select style="border-radius:4px;height:23px;" id="allCateSelect">
				<option value="">全部</option>
			</select>
			<span id="addCate" class="addBtn">+</span>
			
			<div style="margin-top:5px;">
				关键字：&nbsp;<input type="text" class="inputBox" id="keyword" value="" size="50" />&nbsp;&nbsp;
				<input type="button" value="搜索" class="btnStyle1" onclick="ListData(1);" />&nbsp;&nbsp;
				<input type="button" value="重置" style="background-color:red;" class="btnStyle1"  onclick="reset();" />
				<input type="button" value="刷新" class="btnStyle1" onclick="reloadPage();" />
				&nbsp;&nbsp;&nbsp;&nbsp;
			  	<input type="button" style="float:right;margin-right:120px;" value="关键字导入" class="btnStyle1" id="importBtn" />
			  	<input type="hidden" id="sortInput" value="" />
			</div>
  		</div>
  		<div>
  		</div>
	  	<div id="dataDiv">
	  		
	  	</div>
	  	<div id="pageNumDiv">
	  		
	  	</div>
		  	<input type="button" value="批量 ▷" id="batchDo" class="btnStyle1" />
		  	<span id="batchResult" style="color:red;font-weight:bold;margin-left:230px;">&nbsp;</span>
  	</div>
  	
  	
  	<div id="batchDiv" class="batchDiv" style="width:135px;height:173px;position:absolute;display:none;">
  		<div class="divMenu" onclick="batchDelete();">删除</div>
  		<div class="divMenu" onclick="batchCate();">指定类别</div>
  		<div class="divMenu" onclick="batchHot();">加入热门词库</div>
  		<div class="divMenu" onclick="batchDo();">加入测评词库</div>
  	</div>
  	<div id="singleDiv" class="batchDiv1" style="width:135px;height:130px;position:absolute;display:none;">
  		<div class="divMenu" id="sameWordId">加入同义词库</div>
  		<div class="divMenu" id="industryWordId">加入行业词库</div>
  		<div class="divMenu" onclick="batchDo(1);">加入测评词库</div>
  	</div>
  	<input type="hidden" value="" id="hiddenKeyid" />
  	
  	<div id="baseWordEditor" style="width:330px;height:80px;
  			text-align:center;
			box-shadow: 
			  rgba(25, 25, 25, 0.85) 
			  2px  
			  2px  
			  8px; 
			border-radius:5px;background-color:white;display:none;
			padding:30px;">
  		<input type="text" id="baseWordEditorKeyword" style="padding-left:10px;height:25px;width:260px;border:1px solid #aaaaaa;border-radius:4px;" />
  		<input type="hidden" id="baseWordEditorkeyid" /><br /><br />
  		<select style="border-radius:4px;height:23px;" id="baseWordEditorSelect"></select>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  		<input type="button" id="baseWordEditorOk" onclick="saveBaseword();" value="确认" class="btnStyle1" />
  	</div>
  	
  	<input type="hidden" value="添加总词库类别" id="cateTitleInput" />
  	<input type="hidden" value="base_word" id="CATEINFOTYPE" />
  	<#include "./cate_float.ftl" />
  	<#include "./same_word.ftl" />
  	<#include "./industry_word.ftl" />
  	<#include "./upload_temp.ftl" />
  	
  	<script type="text/javascript">
	    //var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://");
	   // document.write(unescape("%3Cscript src='" + _bdhmProtocol + "192.168.167.101/BGFlowRateServer/flowrate/flow_rate.js?lt=span,a,input' type='text/javascript'%3E%3C/script%3E"));
	</script>
  </body>
</html>
